/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import dao.LoginDAO;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author aptech
 */
public class LoginUtil {

    DBConfig con;
    Connection connect;
    String SQL_LOGIN = "select * from Logins where UserName=? and Password=?";

    public boolean loginUser(String username, String password) {
        connect = con.OpenConnect();
        try {
            PreparedStatement pst = connect.prepareStatement(SQL_LOGIN);
            pst.setString(1, username);
            pst.setString(2, password);
            ResultSet rs = pst.executeQuery();
            if (rs != null && rs.next()) {
                return true;
            }
        } catch (SQLException ex) {
            Logger.getLogger(LoginDAO.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            con.CloseConnect(connect);
        }
        return false;
    }
}
